package com.itqf.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/12/18
 * @Time: 上午9:50
 */
public class RabbitMQUtils {


    public static Connection  getConnection(){
        //1.创建连接工厂
        try {
            ConnectionFactory factory = new ConnectionFactory();
            //2.设置host  port  username  password vhost
            factory.setHost("10.9.48.183");
            factory.setPort(5672);
            factory.setUsername("qf");
            factory.setPassword("qf");
            factory.setVirtualHost("/qf");

            //3.创建一个Connection
            Connection connection = factory.newConnection();
              return  connection;
        } catch (IOException e) {
            e.printStackTrace();
        } catch (TimeoutException e) {
            e.printStackTrace();
        }

        return  null;

    }




}
